package resultutil

type ErrorCode struct {
	code      int
	msg       string
	isSuccess bool
}

// 通用错误
var (
	SuccessCode = ErrorCode{
		code:      SuccessRespCode,
		msg:       "success",
		isSuccess: true,
	}
	UnknownErr = ErrorCode{
		code:      -1,
		msg:       "未知错误，请联系管理员处理",
		isSuccess: false,
	}
)

// 用户相关错误
var (
	UserNotFoundErr = ErrorCode{
		code:      UserNotFoundRespCode,
		msg:       "用户不存在",
		isSuccess: false,
	}
	ConfirmPwdErr = ErrorCode{
		code:      UserConfirmPasswordDiffRespCode,
		msg:       "密码不一致",
		isSuccess: false,
	}
	UserAlreadyExistErr = ErrorCode{
		code:      UserAlreadyExistRespCode,
		msg:       "用户已存在",
		isSuccess: false,
	}
	UserRegisterFailErr = ErrorCode{
		code:      UserRegisterFailRespCode,
		msg:       "注册失败",
		isSuccess: false,
	}
	UserNotLoginErr = ErrorCode{
		code:      UserNotLoginRespCode,
		msg:       "请先登录",
		isSuccess: false,
	}
	UserLoginExpireErr = ErrorCode{
		code:      UserLoginExpireRespCode,
		msg:       "用户登录信息过期，请重新登录",
		isSuccess: false,
	}
	UserAddFailErr = ErrorCode{
		code:      UserAddFailErrCode,
		msg:       "添加用户失败",
		isSuccess: false,
	}
	UserDelFailErr = ErrorCode{
		code:      UserDelFailErrCode,
		msg:       "删除用户失败",
		isSuccess: false,
	}
	UserUpdateFailErr = ErrorCode{
		code:      UserUpdateFailErrCode,
		msg:       "更新用户失败",
		isSuccess: false,
	}
)

// 请求相关错误
var (
	RequestParamErr = ErrorCode{
		code:      RequestParamErrCode,
		msg:       "请求参数错误",
		isSuccess: false,
	}
)

// 申请相关错误
var (
	ApplicationNotFoundErr = ErrorCode{
		code:      ApplicationNotFoundRespCode,
		msg:       "申请不存在",
		isSuccess: false,
	}
	ApplicationAlreadyExistErr = ErrorCode{
		code:      ApplicationAlreadyExistRespCode,
		msg:       "申请已存在",
		isSuccess: false,
	}
	ApplicationAddFailErr = ErrorCode{
		code:      ApplicationAddFailErrCode,
		msg:       "添加申请失败",
		isSuccess: false,
	}
	ApplicationDelFailErr = ErrorCode{
		code:      ApplicationDelFailErrCode,
		msg:       "删除申请失败",
		isSuccess: false,
	}
	ApplicationUpdateFailErr = ErrorCode{
		code:      ApplicationUpdateFailErrCode,
		msg:       "更新申请失败",
		isSuccess: false,
	}
)

// 领域相关错误
var (
	FieldNotFoundErr = ErrorCode{
		code:      FieldNotFoundRespCode,
		msg:       "领域不存在",
		isSuccess: false,
	}
	FieldAlreadyExistErr = ErrorCode{
		code:      FieldAlreadyExistRespCode,
		msg:       "领域已存在",
		isSuccess: false,
	}
	FieldAddFailErr = ErrorCode{
		code:      FieldAddFailErrCode,
		msg:       "添加领域失败",
		isSuccess: false,
	}
	FieldDelFailErr = ErrorCode{
		code:      FieldDelFailErrCode,
		msg:       "删除领域失败",
		isSuccess: false,
	}
	FieldUpdateFailErr = ErrorCode{
		code:      FieldUpdateFailErrCode,
		msg:       "更新领域失败",
		isSuccess: false,
	}
)

// 专业相关错误
var (
	MajorNotFoundErr = ErrorCode{
		code:      MajorNotFoundRespCode,
		msg:       "专业不存在",
		isSuccess: false,
	}
	MajorAlreadyExistErr = ErrorCode{
		code:      MajorAlreadyExistRespCode,
		msg:       "专业已存在",
		isSuccess: false,
	}
	MajorAddFailErr = ErrorCode{
		code:      MajorAddFailErrCode,
		msg:       "添加专业失败",
		isSuccess: false,
	}
	MajorDelFailErr = ErrorCode{
		code:      MajorDelFailErrCode,
		msg:       "删除专业失败",
		isSuccess: false,
	}
	MajorUpdateFailErr = ErrorCode{
		code:      MajorUpdateFailErrCode,
		msg:       "更新专业失败",
		isSuccess: false,
	}
)

// 菜单相关错误
var (
	MenuNotFoundErr = ErrorCode{
		code:      MenuNotFoundRespCode,
		msg:       "菜单不存在",
		isSuccess: false,
	}
	MenuAlreadyExistErr = ErrorCode{
		code:      MenuAlreadyExistRespCode,
		msg:       "菜单已存在",
		isSuccess: false,
	}
	MenuAddFailErr = ErrorCode{
		code:      MenuAddFailErrCode,
		msg:       "添加菜单失败",
		isSuccess: false,
	}
	MenuDelFailErr = ErrorCode{
		code:      MenuDelFailErrCode,
		msg:       "删除菜单失败",
		isSuccess: false,
	}
	MenuUpdateFailErr = ErrorCode{
		code:      MenuUpdateFailErrCode,
		msg:       "更新菜单失败",
		isSuccess: false,
	}
)

// 角色相关错误
var (
	RoleNotFoundErr = ErrorCode{
		code:      RoleNotFoundRespCode,
		msg:       "角色不存在",
		isSuccess: false,
	}
	RoleAlreadyExistErr = ErrorCode{
		code:      RoleAlreadyExistRespCode,
		msg:       "角色已存在",
		isSuccess: false,
	}
	RoleAddFailErr = ErrorCode{
		code:      RoleAddFailErrCode,
		msg:       "添加角色失败",
		isSuccess: false,
	}
	RoleDelFailErr = ErrorCode{
		code:      RoleDelFailErrCode,
		msg:       "删除角色失败",
		isSuccess: false,
	}
	RoleUpdateFailErr = ErrorCode{
		code:      RoleUpdateFailErrCode,
		msg:       "更新角色失败",
		isSuccess: false,
	}
)

// 技能相关错误
var (
	SkillNotFoundErr = ErrorCode{
		code:      SkillNotFoundRespCode,
		msg:       "技能不存在",
		isSuccess: false,
	}
	SkillAlreadyExistErr = ErrorCode{
		code:      SkillAlreadyExistRespCode,
		msg:       "技能已存在",
		isSuccess: false,
	}
	SkillAddFailErr = ErrorCode{
		code:      SkillAddFailErrCode,
		msg:       "添加技能失败",
		isSuccess: false,
	}
	SkillDelFailErr = ErrorCode{
		code:      SkillDelFailErrCode,
		msg:       "删除技能失败",
		isSuccess: false,
	}
	SkillUpdateFailErr = ErrorCode{
		code:      SkillUpdateFailErrCode,
		msg:       "更新技能失败",
		isSuccess: false,
	}
)

func (e *ErrorCode) GetCode() int {
	return e.code
}

func (e *ErrorCode) GetMsg() string {
	return e.msg
}
